package com.audaque.springboot.foshanupload.web.redisdemo.service.impl;

import com.audaque.springboot.foshanupload.redis.anno.IntegrationRedisLockAnno;
import com.audaque.springboot.foshanupload.web.redisdemo.service.IntegrationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Slf4j
@Service
public class IntegrationServiceImpl  implements IntegrationService {
    public static String REDIS_KEY_DEAL_ACTION = "run3";

    //SpEL表达式中对常量的引用
    @IntegrationRedisLockAnno(lockKey = "T(com.audaque.springboot.foshanupload.web.redisdemo.service.impl.IntegrationServiceImpl).REDIS_KEY_DEAL_ACTION")
    public void run3(String scanType, Boolean result) throws InterruptedException {
        // 对应切面中的 arguments[1] = "已有任务正在执行，请勿重复请求";
        if (result) {
            log.debug("lock is ready");
        }else{
            log.debug("lock isnot ready");
        }

        // 模拟方法执行耗时
        TimeUnit.SECONDS.sleep(1);

    }

}
